package com.wonking.springbootv2.controller;

import cn.hutool.cache.Cache;
import cn.hutool.cache.CacheUtil;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/local")
public class LocalController {

    @GetMapping("/cache")
    public String cache(){
        try {
            Thread.sleep(10000L);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        Cache cache=CacheUtil.newFIFOCache(3,5);
        for(int i=0;i<10; i++){
            cache.put(i,"a"+i);
            System.out.println(cache.get(i)+" size="+cache.size());
        }
        return "OK";
    }
}
